package net.spacebeeshooter.gui;

import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;

public class TabPanel extends JTabbedPane {

	private static final long serialVersionUID = -441693724422979163L;
	
	private int tabIndex = 0;
	
	public TabPanel(EditorPanel panel) {
		addTab(panel);
	}
	
	public void addTab(EditorPanel component) {
		addTab("Item" + tabIndex, new JScrollPane(component));
		tabIndex ++;
	}
	
	public JTable[] getTables() {
		int tabCount = getTabCount();
		JTable[] tables = new JTable[tabCount];
		for (int i = 0; i != tabCount; i ++) {
			tables[i] = ((EditorPanel)((JScrollPane) getComponentAt(i)).getViewport().getView()).getItemTable();
		}
		return tables;
	}
}
